package morning.cat.springdatademo.util;

import morning.cat.springdatademo.entity.Student;

import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import java.util.Collections;

/**
 * @describe: 类描述信息
 * @author: morningcat.zhang
 * @date: 2019/2/19 11:00 AM
 */
public class StudentUtils {

    public static Student get() {
        Student s = new Student();
        s.setAge(new Random().nextInt(25) + 10);
        s.setName("gozi" + new Random().nextInt(100));
        s.setSid(generateCode());
        return s;
    }

    public static Student get(String code) {
        Student s = new Student();
        s.setAge(new Random().nextInt(25) + 10);
        s.setName("gozi" + new Random().nextInt(100));
        s.setSid(code);
        return s;
    }

    public static List<Student> gets(Integer n) {
        if (n == null || n < 1) {
            return Collections.EMPTY_LIST;
        }
        List<Student> list = new LinkedList<>();
        for (int i = 0; i < n; i++) {
            list.add(get());
        }
        return list;
    }

    public static String generateCode() {
        return "S2012" + (new Random().nextInt(899999) + 100000);
    }
}
